<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <title>YApi 接口管理平台 插件 Wiki</title>
    
        <meta name="keywords" content="api管理,接口管理,接口文档,api文档">
    
    
        <meta name="description" content="YApi 是高效、易用、功能强大的 api 管理平台，旨在为开发、产品、测试人员提供更优雅的接口管理服务。可以帮助开发者轻松创建、发布、维护 API，YApi 还为用户提供了优秀的交互体验，开发人员只需利用平台提供的接口数据写入工具以及简单的点击操作就可以实现接口的管理。">
    

    <link rel="shortcut icon" href="./images/favicon.ico" />
    <link rel="stylesheet" href="source/main.css" />
    
    
      
      <link rel="stylesheet" href="styles/theme.css" />
      
    
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="format-detection" content="telephone=no,email=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
</head>
<body>
    <div class="ydoc">
        <header class="ydoc-header">
            <div class="ydoc-header-area">
                
                <a href="./index.html" class="navbar-brand"><img src="./images/logo_header@2x.png" /> &nbsp;YAPI</a>
                
                <button class="ydocIcon navbar-toggle">&#xf020;</button>
                <nav class="ydoc-nav">
                    <ul class="navbar-left">
                         
                        <li class="">
                            
                            <a href="index.html"></a> 
                        </li>
                        
                        <li class="">
                            
                            <a href="usage.html">使用手册</a> 
                        </li>
                        
                        <li class="">
                            
                            <a href="devops.html">内网部署</a> 
                        </li>
                        
                        <li class="active">
                            
                            <a href="plugin.html">插件 Wiki</a> 
                        </li>
                        
                        <li class="">
                            
                            <a href="qa.html">常见问题</a> 
                        </li>
                        
                        <li class="">
                            
                            <a href="releases.html">版本记录</a> 
                        </li>
                        
                        <li class="">
                            
                            <a href="http://yapi.demo.qunar.com/" target="_blank">产品演示</a> 
                        </li>
                        
                        <li class="">
                            
                            <a href="api.html"></a> 
                        </li>
                         
                    </ul>
                </nav>
            </div>
        </header>
        
        <!-- <header style="height:20px"></header> -->
        
        <!-- Docs page layout -->
        
        <div class="ydoc-banner-bg">
            <div class="ydoc-banner ">
                <div class="ydoc-banner-area">
                    <h1 >插件</h1>
                    <p class="desc ">可根据业务需求，定制化功能</p>
                    
                </div>
            </div>
            

            <div class="ydoc-container">
                 
                <div class="ydoc-container-content ">
                    
                    
                    <div class="content-left staticsidenav" role="complementary">
                        <nav class="docs-sidebar hidden-print hidden-xs hidden-sm">
                            <ul class="nav docs-sidenav">
                                 
                                <!-- <li  > -->
                                <li >
                                    
                                    <a href="redev.html">二次开发</a> 
                                </li>
                                  
                                <!-- <li  > -->
                                <li >
                                    
                                    <a href="plugin-index.html">插件管理</a> 
                                </li>
                                  
                                <!-- <li  > -->
                                <li >
                                    
                                    <a href="plugin-dev.html">插件开发</a> 
                                </li>
                                  
                                <!-- <li  > -->
                                <li >
                                    
                                    <a href="plugin-hooks.html">钩子列表</a> 
                                </li>
                                  
                                <!-- <li  > -->
                                <li >
                                    
                                    <a href="plugin-list.html">插件列表</a> 
                                </li>
                                 
                            </ul>
                        </nav>
                    </div>
                    
                    <div class="content-right markdown-body use-sidebar" role="main">

                         <h2 class="subject" id="安装YApi">安装YApi <a class="hashlink" href="#安装YApi">#</a></h2><p>1.创建工程目录</p>
<pre><code class="lang-bash"><span class="token function">mkdir</span> yapi <span class="token operator">&amp;&amp;</span> <span class="token function">cd</span> yapi
<span class="token function">git</span> clone https://github.com/YMFE/yapi.git vendors --depth<span class="token operator">=</span>1 <span class="token comment"># 或者下载 zip 包解压到 vendors 目录</span>
</code></pre>
<p>2.修改配置</p>
<pre><code class="lang-bash"><span class="token function">cp</span> vendors/config_example.json ./config.json <span class="token comment"># 复制完成后请修改相关配置</span>
<span class="token function">vi</span> ./config.json
</code></pre>
<p>配置如下，主要配置 MongoDB 数据库，以及 Admin 账号。</p>
<pre><code class="lang-json"><span class="token punctuation">{</span>
  <span class="token property">"port"</span><span class="token operator">:</span> <span class="token string">"3011"</span><span class="token punctuation">,</span>
  <span class="token property">"adminAccount"</span><span class="token operator">:</span> <span class="token string">"admin@admin.com"</span><span class="token punctuation">,</span>
  <span class="token property">"db"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">"servername"</span><span class="token operator">:</span> <span class="token string">"127.0.0.1"</span><span class="token punctuation">,</span>
    <span class="token property">"DATABASE"</span><span class="token operator">:</span>  <span class="token string">"yapi"</span><span class="token punctuation">,</span>
    <span class="token property">"port"</span><span class="token operator">:</span> <span class="token number">27017</span><span class="token punctuation">,</span>
    <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"yapi"</span><span class="token punctuation">,</span>
    <span class="token property">"pass"</span><span class="token operator">:</span> <span class="token string">"yapi123"</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token property">"mail"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">"enable"</span><span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
    <span class="token property">"host"</span><span class="token operator">:</span> <span class="token string">"smtp.163.com"</span><span class="token punctuation">,</span>
    <span class="token property">"port"</span><span class="token operator">:</span> <span class="token number">465</span><span class="token punctuation">,</span>
    <span class="token property">"from"</span><span class="token operator">:</span> <span class="token string">"***@163.com"</span><span class="token punctuation">,</span>
    <span class="token property">"auth"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
        <span class="token property">"user"</span><span class="token operator">:</span> <span class="token string">"***@163.com"</span><span class="token punctuation">,</span>
        <span class="token property">"pass"</span><span class="token operator">:</span> <span class="token string">"*****"</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<blockquote>
<p>db.user 和 db.pass 是 mongodb 的用户名和密码，如果没有开启 mongo 认证功能，请删除这两个选项。</p>
</blockquote>
<p>3.安装依赖</p>
<pre><code class="lang-bash"><span class="token function">cd</span> vendors
<span class="token function">npm</span> <span class="token function">install</span> --production --registry https://registry.npm.taobao.org <span class="token comment"># 安装依赖</span>
</code></pre>
<p>4.初始化</p>
<pre><code class="lang-bash"><span class="token function">npm</span> run install-server  <span class="token comment"># 安装程序会初始化数据库索引和管理员账号，管理员账号名可在 config.json 配置</span>
<span class="token comment"># 默认输出</span>
<span class="token comment"># 初始化管理员账号成功,账号名："admin@admin.com"，密码："ymfe.org"</span>
</code></pre>
<p>5.启动开发机</p>
<pre><code class="lang-bash"><span class="token function">npm</span> run dev
<span class="token comment"># 启动服务器后，请访问 127.0.0.1:{config.json配置的端口}，初次运行会有个编译的过程，请耐心等候</span>
<span class="token comment"># 127.0.0.1:3011</span>
</code></pre>
<p>目录结构</p>
<pre><code>|-- config.json
|-- init.lock
|-- log
`-- vendors
    |-- CHANGELOG.md
    |-- LICENSE
    |-- README.md
    |-- client
    |-- common
    |-- config_example.json
    |-- doc
    |-- exts
    |-- nodemon.json
    |-- npm-debug.log
    |-- package.json
    |-- plugin.json
    |-- server
    |-- static
    |-- test
    |-- webpack.alias.js
    |-- yapi-base-flow.jpg
    |-- ydocfile.js
    `-- ykit.config.js
</code></pre><h2 class="subject" id="技术栈说明">技术栈说明 <a class="hashlink" href="#技术栈说明">#</a></h2><p>后端： koa mongoose</p>
<p>前端： react redux</p>
<h2 class="subject" id="启动开发环境服务器">启动开发环境服务器 <a class="hashlink" href="#启动开发环境服务器">#</a></h2><pre><code class="lang-bash">  <span class="token function">cd</span> vendors
  <span class="token function">npm</span> run dev
  <span class="token comment"># 启动服务器后，请访问 127.0.0.1:{config.json配置的端口}，初次运行会有个编译的过程，请耐心等候</span>
</code></pre>
<h2 class="subject" id="启动生产环境服务器">启动生产环境服务器 <a class="hashlink" href="#启动生产环境服务器">#</a></h2><pre><code class="lang-bash">  <span class="token function">cd</span> vendors
  ykit pack -m
  node server/app.js
</code></pre>

                    </div>
                </div>
                 
            </div>
            
        </div>
        
        <footer class="footer">
            <div class="copyright">
                &copy; 2018 <a href="https://ymfe.org">YMFE</a> Team. Build by <a href="http://ued.qunar.com/ydoc/">ydoc</a>&nbsp;
            </div>
        </footer>
    </div>

    
    <div class="open-panel"></div>
    <div class="mask"></div>
     

    <script src="source/main.js"></script>
    <script src="source/app.js"></script>
        

    </body>

</html>
